package qc.module.platform.api.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import qc.module.platform.dto.division.AdminDivisionInfoDto;
import qc.module.platform.dto.division.AdminDivisionQueryConditionDto;
import qc.module.platform.service.AdminDivisionService;

import java.util.List;

/**
 * AdminDivisionController
 *
 * @author QuCheng Tech
 * @create 2023/1/9
 */
@RestController
@RequestMapping("/division")
public class AdminDivisionController {
    private AdminDivisionService adminDivisionService;

    @Autowired
    public void setAdminDivisionService(AdminDivisionService adminDivisionService) {
        this.adminDivisionService = adminDivisionService;
    }

    /**
     * 获取行政区划信息
     *
     * @param dto AdminDivisionQueryConditionDto
     * @return 行政区划信息集合
     * @author QcCheng Tech
     * @since 2023/2/8
     */
    @RequestMapping(value = "/query", method = {RequestMethod.GET, RequestMethod.POST})
    public List<AdminDivisionInfoDto> query(@RequestBody AdminDivisionQueryConditionDto dto) throws Exception {
        return adminDivisionService.query(dto);
    }

    /**
     * 获取下一级行政区划信息
     *
     * @param dto AdminDivisionQueryConditionDto
     * @return 行政区划信息集合
     * @author QcCheng Tech
     * @since 2023/2/8
     */
    @RequestMapping(value = "/childs", method = {RequestMethod.GET, RequestMethod.POST})
    public List<AdminDivisionInfoDto> getChilds(@RequestBody AdminDivisionQueryConditionDto dto) throws Exception {
        return adminDivisionService.getChilds(dto);
    }
}
